package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.OrderRepairFlow;
import com.indusfo.spc.service.OrderRepairFlowService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/27 10:58
 * @Version 1.0
 */

@Controller
@RequestMapping("/service/orderRepairFlow")
public class OrderRepairFlowController {

    @Autowired
    private OrderRepairFlowService orderRepairFlowService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryOrderRepairFlow")
    @ResponseBody
    public JSONObject queryOrderRepairFlow(OrderRepairFlow orderRepairFlow) {
        JSONObject json = orderRepairFlowService.queryOrderRepairFlow(orderRepairFlow);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertOrderRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertOrderRepairFlow(OrderRepairFlow orderRepairFlow) {
        JSONObject json = orderRepairFlowService.insertOrderRepairFlow(orderRepairFlow);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateOrderRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateOrderRepairFlow(OrderRepairFlow orderRepairFlow) {
        JSONObject json = orderRepairFlowService.updateOrderRepairFlow(orderRepairFlow);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteOrderRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteOrderRepairFlow(@RequestParam("orderRepairFlowIds") List<Integer> orderRepairFlowIds, Integer dataState) {
        dataState = 2;
        JSONObject json = orderRepairFlowService.deleteOrderRepairFlow(orderRepairFlowIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedOrderRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedOrderRepairFlow(@RequestParam("orderRepairFlowIds") List<Integer> orderRepairFlowIds, Integer dataState) {
        JSONObject json = orderRepairFlowService.deleteOrderRepairFlow(orderRepairFlowIds, dataState);
        return json;
    }

}
